package com.techsoul.module.tms.controller;

import java.util.List;

import com.techsoul.common.core.pojo.Result;
import com.techsoul.module.tms.pojo.param.TFoFreightOrderItemSearchParam;
import com.techsoul.module.tms.pojo.param.TFoFreightOrderSearchParam;
import com.techsoul.module.tms.pojo.param.TPoPurchaseOrderSaveParam;
import com.techsoul.module.tms.pojo.param.TPoPurchaseOrderSearchParam;
import com.techsoul.module.tms.pojo.vo.TPoPurchaseOrderVo;
import com.techsoul.module.tms.service.ITPoPurchaseOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.core.metadata.IPage;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 前端控制器
 *
 * @author zhaowei
 * @since 2021-05-24
 */
@Api(tags = "物流计划查询")
@RestController
@RequestMapping("/tms/purchaseOrder")
public class TPoPurchaseOrderController {
    @Autowired
    private ITPoPurchaseOrderService service;
    @Autowired
    private Result result;
    @PostMapping
    public String insert(@RequestBody TPoPurchaseOrderSaveParam params) {
        return service.insert(params);
    }

    @DeleteMapping(value = "/{id}")
    public void delete(@PathVariable String id) {
        service.delete(id);
    }

    @PutMapping(value = "/{id}")
    public void update(@PathVariable String id, @RequestBody TPoPurchaseOrderSaveParam params) {
        service.update(id, params);
    }



    @GetMapping(value = "/{id}")
    public Result findById(@PathVariable("id") String id){
        return result.success(service.findById(id));
    }


    @PostMapping(value = "/search")

    public List<TPoPurchaseOrderVo> findAll(@RequestBody TPoPurchaseOrderSearchParam params) {
        return service.findAll(params);
    }





    @ApiOperation("列表-分页")
    @PreAuthorize("hasAnyAuthority('tms:tPoPurchaseOrder:search')")
    @PostMapping("/search/{current}/{pageSize}")
    public Result findAll(@RequestBody TPoPurchaseOrderSearchParam params, @PathVariable Integer current, @PathVariable Integer pageSize) {
        return result.success(this.service.findAll(params, current, pageSize));
    }

}
